<template>
  <div>
    <div class="tempxyz qctable">
      <CCard>
        <CCardHeader>
          <strong class="title">任务列表</strong>
        </CCardHeader>
        <CCardBody class="card-body">
          <div class="cardstyle">
            <div class="rowstyle" @keyup.enter="getTaskTableData()">
              <div class="threePart" style="margin-bottom: 10px">
                <div class="myColtemp layout">
                  <label class="labelName" style="width: 60px">任务名称</label>
                  <Input
                    :title="groupName"
                    v-model="groupName"
                    placeholder="请输入任务名称搜索..."
                    class="pickstyle"
                    maxlength="50"
                    @keyup.enter="hello"
                    id="inputenter"
                  />
                  <!-- <span v-if="changestatus" class="hiddenbit" @click="clearmess">x</span> -->
                </div>
                <div class="startStutes layout">
                  <label class="labelName">开始日期</label>
                  <DatePicker
                    type="date"
                    placeholder="请选择开始日期"
                    v-model="startDate"
                    class="pickstyle"
                    @on-change="onStartTimeChange"
                    :options="startTimeOption"
                    :editable="false"
                  ></DatePicker>
                </div>
                <div class="endDateBtn layout">
                  <label class="labelName" style="width: 60px">结束日期</label>
                  <DatePicker
                    type="date"
                    class="pickstyle"
                    placeholder="请选择结束日期"
                    v-model="endDate"
                    @on-change="onEndTimeChange"
                    :options="endTimeOption"
                    :editable="false"
                  ></DatePicker>
                </div>
              </div>
              <div class="secondPart" style="margin-top: 10px">
                <div class="myColtemp layout">
                  <label style="margin-right: 41px; display: inline-block"
                    >优先级</label
                  >
                  <RadioGroup v-model="priority" class="m_radio_group">
                    <Radio label>全部</Radio>
                    <Radio label="0">普通</Radio>
                    <Radio label="1">优先</Radio>
                  </RadioGroup>
                </div>
                <div class="myColtemp" style="width: 47%">
                  <label
                    class="myColPri"
                    style="margin-right: 25px; display: inline-block"
                    >任务状态</label
                  >
                  <RadioGroup
                    v-model="taskStatus"
                    class="m_radio_group"
                    label="任务状态"
                  >
                    <Radio label>全部</Radio>
                    <Radio label="1">执行中</Radio>
                    <Radio label="8">待执行</Radio>
                    <Radio label="4">成功</Radio>
                    <Radio label="5">失败</Radio>
                    <Radio label="2">暂停</Radio>
                    <Radio label="7">停止</Radio>
                  </RadioGroup>
                </div>
                <div class="searchRight">
                  <div class="btnstyle1">
                    <CButton
                      color="info"
                      @click="getTaskTableData()"
                      class="system-btn-style"
                    >
                      <CIcon name="cil-magnifying-glass" />&nbsp;搜索
                    </CButton>
                    <CButton
                      color="info"
                      @click="clearmess"
                      class="clean system-btn-style"
                    >
                      <!-- <CIcon name="cil-x-circle" />&nbsp; 重置 -->
                      <img
                        src="@/assets/icons/chongzhi.png"
                        style="width: 15px; height: 15px"
                        alt
                      />&nbsp; 重置
                    </CButton>
                  </div>
                </div>
              </div>
            </div>
          </div>

          <div style="height: calc(100% - 160px)">
            <TableList
              ref="table"
              :getColumn="getColumn"
              :getAxios="getAxios"
              class="ivu-tableStyle1"
            >
              <template v-slot:show_imageNumber="data">
                <span>
                  {{ data.data.row.imageNumber }} ({{
                    data.data.row.successNumber
                  }}/{{ data.data.row.failNumber }})
                </span>
              </template>
              <template v-slot:show-status="data">
                <button
                  v-if="data.data.row.status == 1"
                  class="stastusBtn executing"
                >
                  执行中
                </button>
                <button
                  v-if="data.data.row.status == 2"
                  class="stastusBtn pause"
                >
                  暂停
                </button>
                <button v-if="data.data.row.status == 3" style="color: #f9b115">
                  删除
                </button>
                <button
                  v-if="data.data.row.status == 4"
                  class="stastusBtn success"
                >
                  完成
                </button>
                <button
                  v-if="data.data.row.status == 5"
                  class="stastusBtn success"
                >
                  完成
                </button>
                <button v-if="data.data.row.status == 6" style="color: #f9b115">
                  超时
                </button>
                <button
                  v-if="data.data.row.status == 7"
                  class="stastusBtn stop"
                >
                  停止
                </button>
                <button
                  v-if="data.data.row.status == 8"
                  class="stastusBtn pending"
                >
                  待执行
                </button>
              </template>
              <template v-slot:show-level="data">
                <div v-if="data.data.row.status == 8">
                  <CSelect
                    :disabled="
                      $store.getters.getBtnProcessPriority &&
                      $store.getters.getBtnProcessPriority.enableFlag == '1'
                    "
                    horizontal
                    :options="priorityShowList"
                    :value.sync="data.data.row.priority"
                    class="prioritySelect1 selectStyle"
                    @change="selectPriorityChange($event, data.data.row)"
                  ></CSelect>
                </div>
                <div v-else>
                  {{ data.data.row.priority == 0 ? "普通" : "优先" }}
                </div>
              </template>
              <template v-slot:action="data">
                <CButton
                  title="查看子任务"
                  variant="outline"
                  class="textBtnStyle system-btn-style"
                  @click="getInfo(data.data.row)"
                >
                  查看
                </CButton>
                <CButton
                  title="下载"
                  variant="outline"
                  class="textBtnStyle system-btn-style"
                  @click="getTaskDetails(data.data.row)"
                >
                  下载
                </CButton>

                <CButton
                  :disabled="data.data.row.status == 1 ? false : true"
                  v-if="data.data.row.status == 1"
                  title="暂停"
                  variant="outline"
                  class="textBtnStyle system-btn-style"
                  @click="pause(data.data.row)"
                  data-permission="Btn_AllTask_Del"
                >
                  暂停
                </CButton>
                <CButton
                  :disabled="data.data.row.status == 2 ? false : true"
                  title="恢复"
                  v-if="data.data.row.status == 2"
                  variant="outline"
                  class="textBtnStyle system-btn-style"
                  @click="restore(data.data.row)"
                  data-permission="Btn_AllTask_Retore"
                >
                  恢复
                </CButton>
                <CButton
                  :disabled="true"
                  v-if="data.data.row.status != 1 && data.data.row.status != 2"
                  title="暂停"
                  variant="outline"
                  class="disableTextBtnStyle"
                  @click="() => {}"
                  data-permission="Btn_AllTask_Del"
                >
                  暂停
                </CButton>
                <CButton
                  :disabled="data.data.row.status == 1 ? false : true"
                  v-c-tooltip="'终止'"
                  title="终止"
                  v-if="data.data.row.status == 1"
                  variant="outline"
                  class="textBtnStyle system-btn-style"
                  @click="stop(data.data.row)"
                  data-permission="Btn_AllTask_Restar"
                >
                  终止
                </CButton>
                <CButton
                  :disabled="data.data.row.status == 7 ? false : true"
                  title="重启"
                  v-if="data.data.row.status == 7"
                  variant="outline"
                  class="textBtnStyle system-btn-style"
                  @click="reStart(data.data.row)"
                  data-permission="Btn_AllTask_Restar"
                >
                  重启
                </CButton>
                <CButton
                  :disabled="true"
                  title="终止"
                  v-if="data.data.row.status != 1 && data.data.row.status != 7"
                  variant="outline"
                  class="disableTextBtnStyle"
                  @click="() => {}"
                >
                  终止
                </CButton>

                <CButton
                  :disabled="
                    data.data.row.status == 8 ||
                    data.data.row.status == 1 ||
                    data.data.row.status == 4 ||
                    data.data.row.status == 5 ||
                    data.data.row.status == 6
                      ? false
                      : true
                  "
                  v-if="
                    data.data.row.status == 8 ||
                    data.data.row.status == 1 ||
                    data.data.row.status == 4 ||
                    data.data.row.status == 5 ||
                    data.data.row.status == 6
                  "
                  title="删除"
                  variant="outline"
                  class="textBtnStyle system-btn-style"
                  @click="del(data.data.row)"
                  data-permission="Btn_QuaCheck_Del"
                >
                  删除
                </CButton>
                <CButton
                  :disabled="true"
                  v-if="
                    (data.data.row.status != 8) &
                    (data.data.row.status != 1) &
                    (data.data.row.status != 4) &
                    (data.data.row.status != 5) &
                    (data.data.row.status != 6)
                  "
                  title="删除"
                  variant="outline"
                  class="disableTextBtnStyle"
                  @click="() => {}"
                >
                  删除
                </CButton>
              </template>
            </TableList>
          </div>

          <!-- <Table
            :border="true"
            :columns="getColumn"
            :data="data"
            v-resize.quiet="getTableHeight"
            :height="tableHeight"
          >
            <template slot="show_imageNumber" slot-scope="{ row }">
              <span>
                {{ row.imageNumber }} ({{ row.successNumber }}/{{
                  row.failNumber
                }})
              </span>
            </template>
            <template slot="show-status" slot-scope="{ row }">
              <button v-if="row.status == 1" class="stastusBtn executing">
                执行中
              </button>
              <button v-if="row.status == 2" class="stastusBtn pause">
                暂停
              </button>
              <button v-if="row.status == 3" style="color: #f9b115">
                删除
              </button>
              <button v-if="row.status == 4" class="stastusBtn success">
                完成
              </button>
              <button v-if="row.status == 5" class="stastusBtn success">
                完成
              </button>
              <button v-if="row.status == 6" style="color: #f9b115">
                超时
              </button>
              <button v-if="row.status == 7" class="stastusBtn stop">
                停止
              </button>
              <button v-if="row.status == 8" class="stastusBtn pending">
                待执行
              </button>
            </template>
            <template slot="show-level" slot-scope="{ row }">
              <div v-if="row.status == 8">
                <CSelect
                  :disabled="
                    $store.getters.getBtnProcessPriority &&
                    $store.getters.getBtnProcessPriority.enableFlag == '1'
                  "
                  horizontal
                  :options="priorityShowList"
                  :value.sync="row.priority"
                  class="prioritySelect1"
                  @change="selectPriorityChange($event, row)"
                ></CSelect>
              </div>
              <div v-else>{{ row.priority == 0 ? "普通" : "优先" }}</div>
            </template>
            <template slot="action" slot-scope="{ row }">
              <CButton
                title="查看子任务"
                variant="outline"
                class="textBtnStyle system-btn-style"
                @click="getInfo(row)"
              >
                查看
              </CButton>
              <CButton
                title="下载"
                variant="outline"
                class="textBtnStyle system-btn-style"
                @click="getTaskDetails(row)"
              >
                下载
              </CButton>

              <CButton
                :disabled="row.status == 1 ? false : true"
                v-if="row.status == 1"
                title="暂停"
                variant="outline"
                class="textBtnStyle system-btn-style"
                @click="pause(row)"
                data-permission="Btn_AllTask_Del"
              >
                暂停
              </CButton>
              <CButton
                :disabled="row.status == 2 ? false : true"
                title="恢复"
                v-if="row.status == 2"
                variant="outline"
                class="textBtnStyle system-btn-style"
                @click="restore(row)"
                data-permission="Btn_AllTask_Retore"
              >
                恢复
              </CButton>
              <CButton
                :disabled="true"
                v-if="row.status != 1 && row.status != 2"
                title="暂停"
                variant="outline"
                class="disableTextBtnStyle"
                @click="() => {}"
                data-permission="Btn_AllTask_Del"
              >
                暂停
              </CButton>
              <CButton
                :disabled="row.status == 1 ? false : true"
                v-c-tooltip="'终止'"
                title="终止"
                v-if="row.status == 1"
                variant="outline"
                class="textBtnStyle system-btn-style"
                @click="stop(row)"
                data-permission="Btn_AllTask_Restar"
              >
                终止
              </CButton>
              <CButton
                :disabled="row.status == 7 ? false : true"
                title="重启"
                v-if="row.status == 7"
                variant="outline"
                class="textBtnStyle system-btn-style"
                @click="reStart(row)"
                data-permission="Btn_AllTask_Restar"
              >
                重启
              </CButton>
              <CButton
                :disabled="true"
                title="终止"
                v-if="row.status != 1 && row.status != 7"
                variant="outline"
                class="disableTextBtnStyle"
                @click="() => {}"
              >
                终止
              </CButton>

              <CButton
                :disabled="
                  row.status == 8 ||
                  row.status == 1 ||
                  row.status == 4 ||
                  row.status == 5 ||
                  row.status == 6
                    ? false
                    : true
                "
                v-if="
                  row.status == 8 ||
                  row.status == 1 ||
                  row.status == 4 ||
                  row.status == 5 ||
                  row.status == 6
                "
                title="删除"
                variant="outline"
                class="textBtnStyle system-btn-style"
                @click="del(row)"
                data-permission="Btn_QuaCheck_Del"
              >
                删除
              </CButton>
              <CButton
                :disabled="true"
                v-if="
                  (row.status != 8) &
                  (row.status != 1) &
                  (row.status != 4) &
                  (row.status != 5) &
                  (row.status != 6)
                "
                title="删除"
                variant="outline"
                class="disableTextBtnStyle"
                @click="() => {}"
              >
                删除
              </CButton>
            </template>
          </Table>-->
        </CCardBody>
        <!--  <CCardFooter class="page-link">
          <CRow>
            <CCol class="footerPage" style>
              <span class="pageContent">
                每页
                <CSelect
                  @change="getVendorId($event)"
                  :options="[10, 15, 20, 25]"
                  v-model="pageSize"
                  class="selectStyle"
                  style
                />
                条记录。第{{ this.currentPage }}页(总共{{ this.total }}页，{{
                  this.allNum
                }}条记录)
              </span>
              <CPagination
                :activePage.sync="currentPage"
                :pages="total"
                align="end"
                v-if="total != 0"
              />
            </CCol>
          </CRow>
        </CCardFooter>-->
      </CCard>
    </div>
    <div>
      <QualityReport
        ref="refQcReportModal"
        @closed="qcReportModalClosed"
      ></QualityReport>
    </div>
    <Modal
      v-model="delShow"
      draggable
      scrollable
      title="删除主任务"
      :styles="modalStyle"
    >
      <p slot="header" class="modalHeader">
        <img src="@/assets/icons/shanchu.svg" alt />
        <span style="margin-left: 5px">删除主任务</span>
      </p>
      <div class="modalBody">
        <p>删除主任务时与主任务相关的信息都会丢失</p>
        <p>请确认是否删除?</p>
      </div>
      <template #footer class="footerBtns">
        <CButton @click="delCancel" color="info" class="cancel-btn"
          >取消</CButton
        >
        <CButton @click="delOk" color="info" class="system-btn-style"
          >确定</CButton
        >
      </template>
    </Modal>
    <Modal
      v-model="pauseShow"
      draggable
      scrollable
      title="暂停任务"
      :styles="modalStyle"
    >
      <p>确认要暂停任务吗？</p>
      <template #footer class="footerBtns">
        <CButton @click="pauseCancel" color="info" class="cancel-btn"
          >取消</CButton
        >
        <CButton @click="pauseOk" color="info" class="system-btn-style"
          >确定</CButton
        >
      </template>
    </Modal>
    <Modal
      v-model="restoreShow"
      draggable
      scrollable
      title="恢复任务"
      :styles="modalStyle"
    >
      <p>确认要恢复任务吗？</p>
      <template #footer class="footerBtns">
        <CButton @click="restoreCancel" color="info" class="cancel-btn"
          >取消</CButton
        >
        <CButton @click="restoreOk" color="info" class="system-btn-style"
          >确定</CButton
        >
      </template>
    </Modal>
    <Modal
      v-model="restartShow"
      draggable
      scrollable
      title="重启任务"
      :styles="modalStyle"
    >
      <p>确认要重启任务吗？</p>
      <template #footer class="footerBtns">
        <CButton @click="reStartCancel" color="info" class="cancel-btn"
          >取消</CButton
        >
        <CButton @click="reStartOk" color="info" class="system-btn-style"
          >确定</CButton
        >
      </template>
    </Modal>
    <Modal
      v-model="retryShow"
      draggable
      scrollable
      title="重试任务"
      :styles="modalStyle"
    >
      <p>确认要重试任务吗？</p>
      <template #footer class="footerBtns">
        <CButton @click="retryCancel" color="info" class="cancel-btn"
          >取消</CButton
        >
        <CButton @click="retryOk" color="info" class="system-btn-style"
          >确定</CButton
        >
      </template>
    </Modal>
    <Modal
      v-model="stopShow"
      draggable
      scrollable
      title="终止任务"
      :styles="modalStyle"
    >
      <p>确认要终止任务吗？</p>
      <template #footer class="footerBtns">
        <CButton @click="stopCancel" color="info" class="cancel-btn"
          >取消</CButton
        >
        <CButton @click="stopOk" color="info" class="system-btn-style"
          >确定</CButton
        >
      </template>
    </Modal>
  </div>
</template>
<script>
import QualityReport from "../qualityCheck/qualityReport";
import TableList from "../../template/table/TableList";
export default {
  name: "qualityCheck",
  components: { QualityReport, TableList },
  data() {
    return {
      userName: window.sessionStorage.getItem("user"),
      modalStyle: { top: "340px" },
      qcReportModal: false,
      loading: false,
      pauseShow: false,
      restoreShow: false,
      restartShow: false,
      retryShow: false,
      stopShow: false,
      delShow: false,
      priorityShowList: [
        {
          label: "优先",
          value: 1,
        },
        {
          label: "普通",
          value: 0,
        },
      ],
      currentPage: 1,
      allNum: 0,
      pageSize: 15,
      pages: 0,
      total: 0,
      priority: "",
      taskStatus: "",
      searchName: "",
      groupName: "",
      changestatus: false,
      clickId: "",
      workflowGroupId: 1,
      data: [],
      startDate: "",
      endDate: "",
      startTimeOption: {},
      endTimeOption: {},
      children: [],
      condtionList: {
        pageNum: "",
        pageSize: "",
        status: "",
        priorityLevel: "",
        startTime: "",
        endTime: "",
      },
      tableHeight: 0,
      setIntervalTime: "",
      getAxios: {
        url: this.$api.qualityCheckApi.query, //请求路径
        method: "get", //请求方式
        dataList: {
          userName: window.sessionStorage.getItem("user"),
          taskType: 1,//质检
        }, //请求参数
      },
    };
  },
  computed: {
    getColumn() {
      return [
        {
          key: "groupTaskName",
          title: "任务名称",
          align: "left",
          minWidth: 250,
        },
        {
          key: "taskSourceName",
          title: "任务来源",
          align: "center",
          width: "120",
        },
        {
          key: "taskOwner",
          title: "用户名",
          align: "center",
          width: "120",
        },
        {
          key: "createTime",
          title: "开始时间",
          align: "center",
          width: "170",
        },
        {
          key: "endTime",
          title: "结束时间",
          align: "center",
          width: "170",
        },
        { slot: "show-level", title: "优先级", align: "center", width: "110" },
        {
          slot: "show_imageNumber",
          title: "景数(成功/失败)",
          align: "center",
          width: "140",
        },
        {
          slot: "show-status",
          title: "状态",
          align: "center",
          width: "90",
        },
        {
          title: "操作",
          width: "300",
          slot: "action",
          align: "center",
        },
      ];
    },
    getColumnlist() {
      return [
        {
          type: "selection",
          width: 60,
          align: "center",
        },
        {
          key: "productName",
          title: "质检报告文件(文件夹)",
          render: (h, params) => {
            return h("div", [
              h(
                "span",
                {
                  style: {},
                  //就是这里加的属性
                  domProps: {
                    title: params.row.productName,
                  },
                },
                params.row.productName
              ),
            ]);
          },
        },
        {
          title: "操作",
          width: "150px",
          slot: "action",
          align: "center",
        },
      ];
    },
  },
  mounted() {
    // 加载质检界面，检索框显示
    this.$store.commit("setHeaderSation", "yessearch");

    // 查询子任务页面返回调用
    if (this.$route.query.from === "taskChildren") {
      this.currentPage = parseInt(this.$route.query.pageNum);
    }
    this.userName = window.sessionStorage.getItem("user");
    /*  this.getTaskTableData();*/
    this.onStartTimeChange(this.startTime);
    this.onEndTimeChange(this.endTime);
    // 质检创建刷新
    if (this.$route.query.from === "qualityCheck") {
      this.getTaskTableData();
      // this.$forceUpdate()
    }
    if (this.$route.query.from === "qualityCheckCommon") {
      // 重新渲染左侧树  暂时注释掉,修改重新渲染造成的顺序变化
      this.$parent.getTreeList(1);
    }
  },
  methods: {
    getTableHeight(a, b, c, d) {
      console.log(a);
      console.log(b);
      this.tableHeight = parseInt(d) - 20 - 51 - 52 - 77 - 100;
    },
    qcReportModalClosed() {
      this.$refs.refQcReportModal.openOrClose();
    },
    getTaskDetails(item) {
      this.$refs.refQcReportModal.openOrClose();
      this.$refs.refQcReportModal.getTaskDetails(item, "parent");
    },
    getVendorId(event) {
      let tempdata = event.target.value; //获取option对应的value值
      this.pageSize = parseInt(tempdata);
    },

    selectPriorityChange(event, item) {
      let self = this;
      let priority = event.target.value;
      let startWorkflowId = item.id;

      // let url = self.GlobalUrlPath.sthxTaskTaskInfo.updateTaskPriority +priority +"/" +startWorkflowId;
      let url =
        this.$api.qualityCheckApi.updateTaskPriority +
        priority +
        "/" +
        startWorkflowId;
      this.http
        .put(url)
        .then((res) => {
          if (res.data.code == 0) {
            this.$Message.success("修改成功");
            // 修改成功后 刷新右侧table
            // self.getTaskTableData(this.groupId);
          } else {
            this.$Message.error(res.data.message);
          }
          // 修改后,不论成功与否，都刷新右侧table
          self.getTaskTableData();
        })
        .catch((err) => {
          this.$Message.error("修改失败");
        });
    },

    clearmess() {
      this.currentPage = 1;
      this.groupName = "";
      this.startDate = "";
      this.endDate = "";
      this.priority = "";
      this.taskStatus = "";
      this.getTaskTableData();
    },
    delCancel() {
      this.delShow = false;
    },
    del(row) {
      this.delShow = true;
      this.clickId = row.id;
    },
    // 输入框判断 start
    onStartTimeChange(startTime, type) {
      this.endTimeOption = {
        disabledDate(endTime) {
          return endTime < new Date(startTime) || endTime > Date.now();
        },
      };
    },
    onEndTimeChange(endTime, type) {
      this.startTimeOption = {
        disabledDate(startTime) {
          return startTime > new Date(endTime) || startTime > Date.now();
        },
      };
    },
    // end
    getInfo(val) {
      this.clickId = val.id;
      let userLink = `/taskManage/allTask/${val.id}/${val.groupTaskName}`;
      this.$router.push({
        path: userLink,
        query: {
          from: "quality",
          pageNum: this.currentPage,
          taskType: val.taskType,
          //       id: 1
        },
      });
    },
    delOk() {
      let self = this;
      this.delShow = false;
      // let path = this.GlobalUrlPath.workflow.delete + this.clickId;
      let path = this.$api.qualityCheckApi.delete + this.clickId;
      this.http.delete(path).then((res) => {
        if (res.data.code == 0) {
          this.$Message.success("删除成功");
          this.getTaskTableData();
        } else {
          this.$Message.error("删除失败");
        }
      });
      // let statusName = "DELETE";
      // let path =
      //   this.GlobalUrlPath.sthxTaskTaskInfo.updateStatus + "/" + this.clickId;
      // let param = {
      //   statusName: statusName,
      //   _loadingContainer: document.querySelector(".c-main")
      // };
      // this.http.put(path, param).then(res => {
      //   self.loading = false;
      //   if (res.data.code == 0) {
      //     this.getTaskTableData();
      //   } else {
      //     this.$Message.error("状态更改失败");
      //   }
      // });
    },
    pause(val) {
      this.pauseShow = true;
      this.clickId = val.id;
    },
    pauseCancel() {
      this.pauseShow = false;
    },
    pauseOk() {
      let self = this;
      self.pauseShow = false;
      let statusName = "PAUSED";
      // let path =
      //   this.GlobalUrlPath.sthxTaskTaskInfo.updateStatus + "/" + this.clickId;

      let path = this.$api.qualityCheckApi.updateStatus + "/" + this.clickId;

      let param = {
        statusName: statusName,
      };
      this.http.put(path, param).then((res) => {
        self.loading = false;
        if (res.data.code == 0) {
          this.getTaskTableData();
        } else {
          this.$Message.error("状态更改失败");
        }
      });
    },
    restore(val) {
      this.restoreShow = true;
      this.clickId = val.id;
    },
    restoreCancel() {
      this.restoreShow = false;
    },
    restoreOk() {
      let self = this;
      this.restoreShow = false;
      let statusName = "RESUME";
      // let path = this.GlobalUrlPath.sthxTaskTaskInfo.updateStatus + "/" + this.clickId;

      let path = this.$api.qualityCheckApi.updateStatus + "/" + this.clickId;
      let param = {
        statusName: statusName,
      };
      this.http.put(path, param).then((res) => {
        self.loading = false;
        if (res.data.code == 0) {
          this.getTaskTableData();
        } else {
          this.$Message.error("状态更改失败");
        }
      });
    },
    reStart(val) {
      this.restartShow = true;
      this.clickId = val.id;
    },
    reStartCancel() {
      this.restartShow = false;
    },
    reStartOk() {
      let self = this;
      this.restartShow = false;
      let statusName = "RESTART";
      // let path =
      //   this.GlobalUrlPath.sthxTaskTaskInfo.updateStatus + "/" + this.clickId;

      let path = this.$api.qualityCheckApi.updateStatus + "/" + this.clickId;
      let param = {
        statusName: statusName,
      };
      this.http.put(path, param).then((res) => {
        self.loading = false;
        if (res.data.code == 0) {
          this.getTaskTableData();
        } else {
          this.$Message.error("状态更改失败");
        }
      });
    },
    retry(val) {
      this.retryShow = true;
      this.clickId = val.id;
    },
    retryCancel() {
      this.retryShow = false;
    },
    retryOk() {
      let self = this;
      this.retryShow = false;
      let statusName = "RETRY";

      // let path =
      //   this.GlobalUrlPath.sthxTaskTaskInfo.updateStatus + "/" + this.clickId;
      let path = this.$api.qualityCheckApi.updateStatus + "/" + this.clickId;
      let param = {
        statusName: statusName,
      };
      this.http.put(path, param).then((res) => {
        self.loading = false;
        if (res.data.code == 0) {
          this.getTaskTableData();
        } else {
          this.$Message.error("状态更改失败");
        }
      });
    },
    stop(val) {
      this.stopShow = true;
      this.clickId = val.id;
    },
    stopCancel() {
      this.stopShow = false;
    },
    stopOk() {
      let self = this;
      this.stopShow = false;
      let statusName = "STOP";

      // let path =
      //   this.GlobalUrlPath.sthxTaskTaskInfo.updateStatus + "/" + this.clickId;
      let path = this.$api.qualityCheckApi.updateStatus + "/" + this.clickId;
      let param = {
        statusName: statusName,
      };
      this.http.put(path, param).then((res) => {
        self.loading = false;
        if (res.data.code == 0) {
          this.getTaskTableData();
        } else {
          this.$Message.error("状态更改失败");
        }
      });
    },

    download() {},
    // 查询任务列表
    getTaskTableData(data = false) {
      let self = this;
      self.data = [];
      if (self.endDate == "Invalid date") {
        self.endDate = "";
      }
      if (self.startDate == "Invalid date") {
        self.startDate = "";
      }
      let path = this.$api.qualityCheckApi.query;
      let param = {
        currentPageNum: data,
        taskType: self.workflowGroupId,
        status: self.taskStatus,
        priority: self.priority,
        startTime: self.startDate,
        endTime: self.endDate,
        name: self.groupName,
        userName: this.userName,
        // _loadingContainer: document.querySelector(".container")
      };
      this.$refs.table.getRefreshTable(param, path);
      /* this.http.get(path, param).then((res) => {
        // self.loading = false;
        if (res.data.code == 0) {
          if (!res.data.data) return;
          self.allNum = res.data.data.total;
          self.total = Math.ceil(res.data.data.total / self.pageSize);

          self.data = res.data.data.dataList;

          for (let i = 0; i < self.data.length; i++) {
            self.data[i].number =
              (self.currentPage - 1) * this.pageSize + i + 1;
            if (self.data[i].endTime == null) {
              self.data[i].endTime = "";
            }
          }
        } else {
          this.$Message.error("查询出错");
        }
      });*/
    },
  },

  activated() {
    let that = this;
    that.getTaskTableData(true);
    this.setIntervalTime = setInterval(function () {
      that.getTaskTableData(true);
    }, 5000);
  },
  deactivated() {
    clearInterval(this.setIntervalTime);
  },
  watch: {
    data(newVal, oldVal) {
      this.$nextTick(function () {
        this.GlobalPermissionRender.render();
      });
    },
    groupName(newVal, oldVal) {
      if (newVal.length >= 50) {
        this.$Message.warning("任务名称长度不得超过50个字符");
      } else {
      }
      // if(newVal != ""){
      // this.changestatus = true
      // }else{
      // this.changestatus = false
      // }
    },
    pageSize(newVal, oldVal) {
      this.pageSize = newVal;
      this.getTaskTableData();
    },
    currentPage(newVal, oldVal) {
      this.currentPage = newVal;
      this.getTaskTableData();
    },
    startDate(newVal, oldVal) {
      this.startDate = this.$moment(newVal).format("YYYY-MM-DD HH:mm:ss");
    },
    endDate(newVal, oldVal) {
      this.endDate = this.$moment(newVal).format("YYYY-MM-DD HH:mm:ss");
    },
  },
};
</script>



<style lang="scss" scoped>
/deep/.page-item.active .page-link {
  background-color: var(--label-font-color, #5d8bc4);
}
.myCol {
  margin-left: 10px;
  display: flex;
  align-items: center;
}

.myColPri {
  margin-right: 10px;
}

.myColtemp {
  display: flex;
  align-items: center;
  margin-left: 5px;
  width: 33.3%;
}

.search {
  display: flex;
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.76563rem;
  line-height: 1.5;
  border-radius: 0.2rem;
  width: 50px;
}

.labelName {
  margin-right: 25px;
  margin-bottom: 0px;
}

.m_radio_group {
  height: 21px;
  margin-top: -9px;
}

.m_radio_group label {
  margin: 0;
  margin-right: 14px;
}

.strongstyle {
  font-size: 18px;
}

// .rowstyle {
//   margin-bottom: 20px;
// }

.pickstyle {
  width: 58%;
}

.modal-dialog {
  margin-top: 20%;
}

.clean {
  margin-left: 10px;
  margin-right: 18px;
}

.listbtn {
  margin-left: 23px;
}

.page-link {
  cursor: pointer;
  /* border: 1px solid #d8dbe0;*/
  border-top: 0;
  bottom: 12px;
}

footer.page-link {
  padding-right: 19px;
  width: calc(100% + 2px);
}

.pageContent {
  margin-right: 26px;
  font-size: 14px;
}

.selectStyle {
  display: inline-block;
  width: 100px;
  margin-right: 5px;
}

.footerPage {
  display: flex;
  justify-content: flex-end;
  cursor: pointer;
  color: black;
}

.threePart,
.secondPart {
  display: flex;
  justify-content: space-between;
}

.layout {
  width: 33.3%;
}

.btnStyle {
  margin-right: -6px;
}
.btnStyle:hover {
  background-color: rgba(0, 0, 0, 0.2);
}
.searchRight {
  width: 18%;
}
.searchRight .btnstyle1 {
  right: 2%;
}

@media screen and (min-width: 1920px) {
  .btnstyle1 {
    right: 5.8% !important;
  }
}

.rowstyle {
  margin-bottom: 0;
}

.mainTable {
  height: calc(100% - 158px);
}

.tempxyz .card-body {
  overflow-y: auto;
  padding: 0 20px;
  height: calc(100% - 50px) !important;
}


.selectStyle {
  margin: 0;
}
/deep/.form-control {
  padding: 0;
}
/*.ivu-tableStyle{
  height: calc(100% - 98px);
}*/
</style>
<style>
.cardstyle {
  margin: 10px 0;
}
.mainTable > div {
  height: 100% !important;
  width: 100% !important;
  border: 1px solid #d8dbe0;
  border-left: 0;
  border-right: 0;
}

.table {
  margin-bottom: 0;
}

.table th {
  border-top: 0;
}

.selectData {
  padding: 0;
  flex: 1;
}

.prioritySelect {
  width: 100%;
  flex: 1;
}

.ivu-tableStyle /deep/ .ivu-table-body {
  overflow-x: auto;
}
</style>
